
    <div class=" fixed-bar">
        <form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <div class="layui-inline removeStat">
                <label class="layui-form-label">日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="create_date_range" value="" readonly="" id="create_date_range" lay-verify="" placeholder="选择下单日期" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">来源帐号</label>
                <div class="layui-input-inline">
                    {:Form::select('is_auto_import', '', [''=> '请选择']+config('mimo.order_from'), '', '')}
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所属父工厂名称</label>
                <div class="layui-input-inline">
                  {:Form::select('factory_id', '', $factoryKV, '', '')}
                </div>
            </div>
            <div class="layui-inline layui-upload">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
            </div>
        </div>
    </div>

<table id="dataTable" lay-filter="demoEvent"></table>

{include file="system@block/layui" /}

<script type="text/html" title="操作按钮模板" id="buttonTpl">
<!--    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe" hisi-data="{width: '470px', height: '600px'}" title="修改组别">修改</a>-->
<!--	<a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>-->
</script>

<script type="text/html" title="排序模板" id="sortTpl">
    <input type="text" class="layui-input hisi-ajax-input input-sort" onkeyup="value=value.replace(/[^\d]/g,'')" value="{{ d.order }}" data-value="{{ d.id }}" data-href="{:url('sort')}?id={{ d.id }}&field=order">
</script>

<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
<!--        <a href="{:url('add')}" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-circle-fine hisi-iframe" hisi-data="{width: '470px', height: '600px'}" title="添加组别">&nbsp;添加</a>-->
<!--		<a data-href="{:url('del')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon layui-icon-close red">&nbsp;删除</a>-->
<!--        <a data-href="{:url('editUnit')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon layui-icon-close "  >&nbsp;确定</a>-->
    </div>
    <span id="TotalPer">
		 &nbsp;&nbsp;&nbsp;断码率快捷设置：
        <input type="text" name="stock_code_all_num"  placeholder="" style="width: 50px;">&nbsp;&nbsp;
        <a onclick="set_stock_code_all_num(this)" href="#">确认设置</a>&nbsp;&nbsp;
	</span>
</script>
<script type="text/html" id="updateTimeTpl">
    <div>{{layui.util.toDateString(d.update_time * 1000) }}</div>
</script>
<script src="__PUBLIC_JS__/jquery.2.1.4.min.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/vue@3.2.26/dist/vue.global.js"></script>
<script type="text/javascript">
    var now_page_data={};
    layui.use(['table', 'laydate', 'form', 'laytpl','tool','layer'], function() {
        var $ = layui.jquery;
        var table = layui.table;
        var laydate = layui.laydate;
        var form = layui.form;
        var layer = layui.layer;

        laydate.render({
            elem: '#create_date_range'
            ,range: '~'
            ,theme: 'molv'
            ,mark: {'{:$today}':''}
            ,change: function(value, date, endDate){
                $('#create_date_range').val(value);
                $('#layui-laydate1').remove();//关闭面板
            }
        });
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,cols: [[ //表头
                // {type:'checkbox', fixed:'left' ,width:60 }
                // ,{field: 'id', title: '编号' ,width:60}
                ,{field: 'sdate', title: '日期' ,width:120}
                ,{field: 'is_auto_import_txt', title: '来源帐号' ,width:120}
                ,{field: 'factory_name_html', title: '父工厂名称' ,width:120}
                ,{field: 'num_html', title: '统计款' ,width:120}
                ,{field: 'num_1_html', title: '正常' ,width:120}
                ,{field: 'num_3_html', title: '断码' ,width:120}
                ,{field: 'num_1_num_3_html', title: '断码率' ,width:120 }
                ,{field: 'num_1_num_3_end', title: '断码率目标' ,width:120 }
            ]]
            ,done: function(res, curr, count) {
                now_page_data=res;
                var data = res.data;
                var status = res.status;
                layui.form.render();
                table.on('edit(demoEvent)', function(obj){
                    var value = obj.value //得到修改后的值
                        ,d = obj.data //得到所在行所有键值
                        ,field = obj.field; //得到字段
                    var id=d.id;
                    d.edit_field=obj.field;
                    d.edit_value=obj.value;
                    $.ajax({
                        type: "POST",
                        url: "{:url('editUnit')}",
                        data: d,
                        dataType:"json",
                        success: function(res){
                            if (res.code == 1) {
                                layer.msg(res.msg, {icon: 1});
                                layui.form.render();
                            } else {
                                layer.msg(res.msg, {icon: 2,anim: 6});
                            }
                        }
                    });
                });
                //断码率设置 data-edit="text" style="border-bottom:2px dotted #5FB878;"
                $.each(now_page_data.data, function(i, n){
                    if(n.id<0){
                        $('[data-index="'+i+'"]').find('[data-field="num_1_num_3_end"]').attr('data-edit','text');
                        $('[data-index="'+i+'"]').find('[data-field="num_1_num_3_end"]').attr('style','border-bottom:2px dotted #5FB878;');
                    }
                });
            }
        });

        //自定页
        window.set_stock_code_all_num = function(_this)  {
            var ids=new Array();
            $.each(now_page_data.data, function(i, n){
                ids.push(n.id);
            });
            var stock_code_all_num=$('[name="stock_code_all_num"]').val();
            $.ajax({
                type: "POST",
                url: "{:url('editUnit')}",
                data: {edit_field:'stock_code_all_num',edit_value:stock_code_all_num,ids:ids},
                dataType:"json",
                success: function(res){
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1});
                        layui.form.render();
                    } else {
                        layer.msg(res.msg, {icon: 2,anim: 6});
                    }
                }
            });
        }
    });
    
    
</script>